import { serviceConfig } from '@/config/request/swaggerServiceConfig';
import { Api as Customer } from './customer';
import { Api as Order } from './order';


export const Api = { Customer, Order };

const warpperServiceConfig = (serviceConfig: any, ctx: { name: string; }) => {
    const newConfig = { ...serviceConfig };
    if (newConfig.baseURL) {
        newConfig.baseURL = newConfig.baseURL + '/' + ctx.name;
    }
    return newConfig;
};

const customer = new Customer(warpperServiceConfig(serviceConfig, { name: 'customer' }));
const order = new Order(warpperServiceConfig(serviceConfig, { name: 'order' }));

export const apiInstanceList = [{ key: 'customer', instance: customer }, { key: 'order', instance: order }];

export const api = { customer, order };